package com.share.tool.m2d.kundb.count;


import com.share.common.utils.FileUtil;
import com.share.tool.m2d.kundb.tablestructure.DbMainV2;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class CountMain {
    public static void main(String[] args) {
        String countsql = "select count(1),\"#table\" from  #table UNION all";
        //读取配置
        String productConfigurePath = DbMainV2.class.getClassLoader().getResource("kundb\\count.txt").getPath();
        List<String> list = FileUtil.readByLine(productConfigurePath);
        StringBuffer sb = new StringBuffer();
        for (String line : list) {
            line = line.trim();
            if (StringUtils.isBlank(line)) {
                continue;
            }

            String s = countsql.replaceAll("#table", line);

            sb.append(s);
            sb.append(System.lineSeparator());

        }

        System.out.println(sb.toString());
    }
}
